package com.cnt.controller;

import com.cnt.dto.MoneyDTO;
import com.cnt.entity.DonationRecords;
import com.cnt.entity.MoneyLog;
import com.cnt.service.DonationRecordsService;
import com.cnt.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/money")
public class MoneyController {

    @Autowired
    private DonationRecordsService donationRecordsService;

    @GetMapping("/donationRecordsByUserId")
    public ResultVo<List<DonationRecords>> getDonationRecordsByUserId(@RequestParam Integer userId){
        return donationRecordsService.getDonationRecordsByUserId(userId);
    }

    @GetMapping("/donationRecords")
    public ResultVo<List<DonationRecords>> getDonationRecordsByUserId(){
        return donationRecordsService.getDonationRecords();
    }

    @GetMapping("/getMoneyLog")
    public ResultVo<List<MoneyLog>> getMoneyLog(){
        return donationRecordsService.getMoneyLog();
    }

    @PostMapping("/recharge")
    public ResultVo<String> recharge(@RequestBody MoneyDTO moneyDTO){
        return donationRecordsService.recharge(moneyDTO);
    }

    @PostMapping("/withdraw")
    public ResultVo<String> withdraw(@RequestBody MoneyDTO moneyDTO){
        return donationRecordsService.withdraw(moneyDTO);
    }

    @PostMapping("/contribution")
    public ResultVo<String> contribution(@RequestBody MoneyDTO moneyDTO){
        return donationRecordsService.contribution(moneyDTO);
    }

    @PostMapping("/donationRefund")
    public ResultVo<String> donationRefund(@RequestBody MoneyDTO moneyDTO){
        return donationRecordsService.donationRefund(moneyDTO);
    }

    @GetMapping("/moneyInfo")
    public ResultVo<Double> getMoneyInfo(@RequestParam Integer userId){

        return donationRecordsService.getMoneyInfo(userId);
    }

    @GetMapping("/rechargeByUserId")
    public ResultVo<List<Map<String,Object>>> rechargeByUserId(@RequestParam Integer userId){
        return donationRecordsService.rechargeByUserId(userId);
    }

    @GetMapping("/withdrawByUserId")
    public ResultVo<List<Map<String,Object>>> withdrawByUserId(@RequestParam Integer userId){
        return donationRecordsService.withdrawByUserId(userId);
    }

    @GetMapping("/refundByUserId")
    public ResultVo<List<Map<String,Object>>> refundByUserId(@RequestParam Integer userId){
        return donationRecordsService.refundByUserId(userId);
    }
}
